package com.etheart.framework.core.context;

import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;

public class ApplicationContextHolder implements ApplicationContextAware {
	private static final ThreadLocal<ApplicationContext> contextHolder = new ThreadLocal<ApplicationContext>();

	public void setApplicationContext(ApplicationContext applicationContext)
			throws BeansException {
		contextHolder.set(applicationContext);
	}

	public static ApplicationContext getApplicationContext() {
		return contextHolder.get();
	}

	public static void clearContext() {
		contextHolder.set(null);
	}
}
